package com.csnf.demo1.dao.impl;

import com.csnf.demo1.dao.StudentDao;
import com.csnf.demo1.entity.Student;
import com.csnf.demo1.util.JdbcUtil;

import java.util.List;
import java.util.Objects;

public class StudentDaoImpl implements StudentDao {

    @Override
    public Boolean addStudent(Student student) {
        String sql="INSERT INTO student(id,name,gender,birthday,clazz,state) VALUES(null,?,?,?,?,'1')";
        return JdbcUtil.updateTable(sql,student.getName(),student.getGender(),student.getBirthday(),student.getClazz());
    }

    @Override
    public List<Student> getStudentById(Integer id) {
        String sql="SELECT * FROM student WHERE id=?";
        return JdbcUtil.queryTable(Student.class,sql,id);
    }

    @Override
    public List<Student> getAllStudent() {
        String sql="SELECT * FROM student";
        return JdbcUtil.queryTable(Student.class,sql);
    }
}
